from pygds import GDS
from py2neo import Graph
URI = "bolt://localhost:7687"
AUTH = ("neo4j", "123456")
import os
import pandas as pd

graph_link = Graph("http://localhost:7474", username="neo4j", password="123456")

if not os.path.exists('nodevec/all.csv'):
    with GDS(URI, auth=AUTH) as gds:
        # create the projected graph
        # NB: make sure a graph with the same does not already exists
        # otherwise run CALL gds.graph.drop("MyGraph")


        result = gds.beta.graphSage.stream(
            "crm",
            {
                'modelName': 'multiLabelModel'
            }
        )

        _tmp = pd.DataFrame.from_records(result)
        _tmp.to_csv("nodevec/all.csv")
else:
    _tmp = pd.read_csv('nodevec/all.csv')


node_cyper = 'match (n:`企业`) return n'
qiye_reuslt = graph_link.run(node_cyper)


